using System;
using System.Collections.Generic;
using Be.Timvw.Framework.Collections.Generic;
using Be.Timvw.Framework.Domain.Generators;

namespace Be.Timvw.Framework.Domain.Ranges
{
    public class DateTimeRange : Range<DateTime>, IDiscreteValuesRange<DateTime>
    {
        #region Private Fields

        private readonly DiscreteValuesRange<DateTime> discreteRange;

        #endregion

        #region Constructors

        public DateTimeRange(DateTime begin, DateTime end)
        : base(begin, end)
        {
            this.discreteRange = new DiscreteValuesRange<DateTime>(begin, end, new SecondsGenerator());
        }

        #endregion

        #region IDiscreteValuesRange<DateTime> Members

        public bool IsCoveredBy(IEnumerable<IDiscreteValuesRange<DateTime>> ranges)
        {
            return this.discreteRange.IsCoveredBy(ranges);
        }

        public IEnumerable<DateTime> Values
        {
            get { return this.discreteRange.Values; }
        }

        #endregion

        #region Public Methods

        public bool IsCoveredBy(IEnumerable<DateTimeRange> ranges)
        {
            return this.discreteRange.IsCoveredBy(EnumerableHelper.Convert<DateTimeRange, IDiscreteValuesRange<DateTime>>(ranges));
        }

        #endregion
    }
}